package ar.uba.fi.algo3.java2d.ejemplo3;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagLayout;
import java.awt.Panel;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;

public class PanelMutante extends Panel {

	private static final long serialVersionUID = 1L;

	/**
	 * This is the default constructor
	 */
	public PanelMutante() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(300, 200);
		this.setLayout(new GridBagLayout());
	}

	public void Mutar(){
		contador++;
		this.repaint();
	}
	
	private int contador;
	
	@Override
	public void paint(Graphics g){
		if(contador==0)
			return;
		
		int estado = (contador % 3);
		
		if( estado == 0)
			this.dibujarCirculo(g);
		
		if( estado == 1)
			this.dibujarCuadrado(g);

		if(estado == 2)
			this.dibujarRectangulo(g);
		
	}

	private void dibujarRectangulo(Graphics g) {
		Graphics2D g2 = (Graphics2D)g;
		Shape cuadrado = new Rectangle2D.Float(20,20,20,20);
		g2.setColor(Color.CYAN);
		g2.draw(cuadrado);	
	}

	private void dibujarCuadrado(Graphics g) {
		g.setColor(Color.BLUE);
		g.fill3DRect(50, 30, 60, 60, false);	
	}

	private void dibujarCirculo(Graphics g) {
		g.setColor(Color.RED);
		g.fillOval(50, 50, 60, 40);	
	}
}
